{% load i18n%}

$('.repo-transfer-btn').click(function(){
    var btn_ct = $(this).parents('td'),
        repo_id = btn_ct.data('id'),
        repo_name = btn_ct.attr('data-name'),
        form = $('#repo-transfer-form');

    form.modal({appendTo:'#main'});
    $('#simplemodal-container').css({'width':'auto', 'height':'auto'});

    var detail = $('.detail', form);
    detail.html(detail.html().replace('%(lib_name)s', '<span class="op-target">' + HTMLescape(repo_name) + '</span>'));

    $('[name="email"]', $('#repo-transfer-form')).select2($.extend({
        width: '268px',
        maximumSelectionSize: 1,
        placeholder: "{% trans "Search user or enter email" %}"
    }, userInputOPtionsForSelect2('{% url 'search-user' %}')));

    $('input[name="repo_id"]', form).val(repo_id);
    return false;
});

$('#repo-transfer-form').submit(function() {
    var form = $(this),
        form_id = form.attr('id'),
        email = $.trim(form.children('[name="email"]').val());

    if (!email) {
        return false;
    }
});

$('#main-panel').removeClass('ovhd');
{% include 'snippets/repo_del_js.html' %}
